/**
 * 后台返回数据的类型
 */
export type Token = {
  token: string
  refresh_token: string
}
export type UserInfo = {
  id: string
  name: string
  photo: string
  art_count: number
  follow_count: number
  fans_count: number
  like_count: number
}
export type EditInfo = {
  id: string
  name: string
  photo: string
  mobile: string
  gender: string
  birthday: string
  intro: string
}
export type Photo = {
  id: string
  photo: string
}
export type Edit = Partial<EditInfo>
//============创建接口返回类型的工具类型
// axios 请求的响应类型
type ApiResponse<Data> = {
  message?: string
  data: Data
}
// 用户频道类型
export type Channel = {
  id: number
  name: string
}
export type UserChannel = {
  channels: Channel[]
}
// 文章列表类型
export type ArticlesItem = {
  art_id: string
  aut_id: string
  aut_name: string
  comm_count: number
  cover: {
    type: 0 | 1 | 3
    images: string[]
  }
  pubdate: string
  title: string
}

export type Articles = {
  pre_timestamp: number
  results: ArticlesItem[]
}
// 文章详情类型
export type ArticlesDetail = {
  art_id: string
  title: string
  pubdate: string
  aut_id: string
  aut_name: string
  aut_photo: string
  is_followed: boolean
  attitude: number
  content: string
  is_collected: boolean
  // 接口中缺失
  comm_count: number
  like_count: number
  read_count: number
}

// 搜索关键词
type SearchKey = {
  options: string[]
}
// 查询结果 
type ResultList = {
  page: number
  per_page: number
  total_count: number
  results: ArticlesItem[]
}

// 评论项的类型
export type ArticleCommentItem = {
  com_id: string
  aut_id: string
  aut_name: string
  aut_photo: string
  like_count: number
  reply_count: number
  pubdate: string
  content: string
  is_liking: boolean
  is_followed: boolean
}
// 文章评论的类型
export type ArticleComment = {
  total_count: number
  end_id: string | null
  last_id: string | null
  results: ArticleCommentItem[]
}
// 文章发布评论的类型
// 注意：接口文档中的返回类型与后台接口返回数据不一致
export type AddArticleCommnet = {
  com_id: string
  new_obj: ArticleCommentItem
  target: string
}


// 登录类型
export type LoginResponse = ApiResponse<Token>
// 用户类型
export type UserResponse = ApiResponse<UserInfo>
// 用户类型
export type EditResponse = ApiResponse<EditInfo>
// 修改头像
export type PhotoResponse = ApiResponse<Photo>
// 频道类型
export type UserChannelResponse = ApiResponse<UserChannel>
// 文章列表
export type ArticlesResponse = ApiResponse<Articles>
// 文章详情
export type ArticlesDetailResponse = ApiResponse<ArticlesDetail>
// 搜索关键词
export type SearchKeyResponse = ApiResponse<SearchKey>
// 查询结果
export type ResultListResponse = ApiResponse<ResultList>
// 评论类型
export type ArticleCommentResponse = ApiResponse<ArticleComment>
// 发布评论
export type AddArticleCommnetResponse = ApiResponse<AddArticleCommnet>